///////////////////////////////////////////////////////////////////////////////
// Project: Hoyo Client Game
//
// hy_db_item_logic.cpp
// Created: 2013-13-3
// Author: Like Cheng
///////////////////////////////////////////////////////////////////////////////

#include "hy_db_item_logic.h"

#include "hy_db/hy_db_logic.h"
#include "hy_db/hy_db_const.h"

#include "hy_net/hy_network_message.h"
#include "hy_net/hy_network_server.h"
#include "hy_net/hy_network_default.h"

#include "hy_common_func/hy_language_logic.h"

USING_NS_HY_NETWORK;
hy_db_item_logic* hy_db_item_logic_instance = NULL;

hy_db_item_logic::hy_db_item_logic()
{

}

hy_db_item_logic::~hy_db_item_logic()
{

}

hy_db_item_logic* hy_db_item_logic::instance()
{
	if( hy_db_item_logic_instance == NULL )
		hy_db_item_logic_instance = new hy_db_item_logic;
	return hy_db_item_logic_instance;
}

void hy_db_item_logic::purge_instance()
{
	DEL_POINTER( hy_db_item_logic_instance );
}


bool hy_db_item_logic::load_item_template_data()
{
	std::string table = HY_DB_AND( HY_DB, HY_SERVER_TABLE_SKILL );

	mongo::BSONObjBuilder con;
	Json::Value return_val; 
	if( !hy_db_logic::instance(DS)->load_collection_data( con, table.c_str(), return_val ) )
		return false;

	/*
	hy_server_skill_mgr::instance()->get_server_skill_data_map().clear();
	for( Json::Value::iterator it = return_val.begin(); it != return_val.end(); it++ )
	{
		Json::Value& v = *it;

		int id = v["id"].asInt();
		std::string cname = v["cname"].asString();

		hy_server_skill_data* d = new hy_server_skill_data;
		d->init();
		d->set_id( id );
		d->set_value( v );

		hy_server_skill_mgr::instance()->add_server_skill_data( d );
	}
	*/
	return true;
}


bool hy_db_item_logic::reload_item_template_data()
{
	return true;
}
bool hy_db_item_logic::load_player_item_data()
{
	return true;
}

